using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using log4net;

namespace ICeFramework.Win.UI.ExceptionHandler
{
    public static class SimpleMessage
    {
        private static readonly ILog _log = LogManager.GetLogger(typeof(ExceptionHandler));

        public static DialogResult Show(string message, MessageBoxIcon icon)
        {
            string caption = string.Empty;
            switch (icon)
            { 
                case MessageBoxIcon.Information:
                    caption = "Information";
                    _log.Info(message);
                    break;
                case MessageBoxIcon.Error:
                    caption = "Error";
                    _log.Error(message);
                    break;
                case MessageBoxIcon.Warning:
                    caption = "Warning";
                    _log.Warn(message);
                    break;
            }
            
            return MessageBox.Show(message, caption, MessageBoxButtons.OK, icon);
        }

        public static DialogResult Show(string message, MessageBoxIcon icon, MessageBoxButtons buttons, MessageBoxDefaultButton defaultButton)
        {
            string caption = string.Empty;
            switch (icon)
            {
                case MessageBoxIcon.Information:
                    caption = "Information";
                    break;
                case MessageBoxIcon.Error:
                    caption = "Error";
                    break;
                case MessageBoxIcon.Warning:
                    caption = "Warning";
                    break;
                case MessageBoxIcon.Question:
                    caption = "Question";
                    break;
            }
            DialogResult dl = MessageBox.Show(message, caption, buttons, icon, defaultButton);
            _log.Info(String.Format("{0}: {1} ({2})", caption, message, dl.ToString()));
            return dl;
        }

        public static void Log(string message)
        {
            _log.Info(message);
        }
    }
}
